package com.example.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

class MyThread1 implements Runnable {

	@Override
	public void run() {

	}

}

class MyThread2 implements Callable<Integer> {

	@Override
	public Integer call() throws Exception {
		boolean flag = true;
		if (flag) {
			throw new RuntimeException("系统异常");
		}
		return 200;
	}

}

public class Demo1 {

	public static void main(String[] args) {
		new Thread(new MyThread1(), "AA").start();
		
		FutureTask<Integer> futureTask = new FutureTask<Integer>(() -> {
			return 200;
		});
		FutureTask<Integer> task = new FutureTask<Integer>(new MyThread2());
		new Thread(task).start();
		try {
			Integer result = task.get();
			System.out.println("result: " + result);
		} catch (Exception e) {
			e.addSuppressed(e);
		}
		
	}
}
